package com.lovo.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.system.dto.RoleDto;
import com.lovo.system.mapper.RoleMapper;
import com.lovo.system.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, RoleDto> implements IRoleService {

    @Autowired
    RoleMapper roleMapper;

    @Override
    public IPage<RoleDto> cutByItem(int curPage, int pageSize) {
        return roleMapper.selectPage(new Page<>(curPage,pageSize),new QueryWrapper<>());
    }

    @Override
    public List<RoleDto> selectList() {
        return roleMapper.selectList(new QueryWrapper<>());
    }

    @Override
    public RoleDto selectOne(int id) {
        return roleMapper.queryById(id);
    }

    @Override
    public int insertRole(RoleDto roleDto) {
        roleMapper.insert(roleDto);
        return roleDto.getId();
    }

    @Override
    public void deleteRole(int roleId) {
        roleMapper.deleteById(roleId);
    }

    @Override
    public List<Integer> selectUserRoleNow(int id) {
        return roleMapper.selectUserRoleNow(id);
    }

    @Override
    public List<String> selectRolePer(List<Integer> ids) {
        ids.add(0);
        return roleMapper.selectRolePer(ids);
    }

    @Override
    public List<Integer> selectRolePerNow(int id) {
        return roleMapper.selectRolePerNow(id);
    }

    @Override
    public List<Integer> selectRolePerIds(List<Integer> ids) {
        ids.add(0);
        return roleMapper.selectRolePerIds(ids);
    }

}
